package com.yidu.t299.dao.lzy;

import com.yidu.t299.domain.lzy.Cooperate;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CooperateMapper {
    /**
     * 根据计划编号删除该市场计划信息
     * @param buddyId
     * @return 影响的行数(返回1则为成功)
     */
    @Delete({
            "delete from cooperate" +
            " where buddy_id = #{buddyId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer buddyId);

    /**
     * 添加校区信息
     * @param record 校区对象
     * @return 影响的行数(返回1则为成功)
     */
    @Insert({
            "insert into cooperate (buddy_id, buddy_unit,custom_count)" +
                    "values (#{buddyId,jdbcType=INTEGER},#{buddyUnit,jdbcType=VARCHAR},#{customCount,jdbcType=VARCHAR})"
    })
    int insert(Cooperate record);

    /**
     * 根据校区编号查询指定的信息
     * @param buddyId 校区编号
     * @return 校区对象
     */
    @Select({
            "select" +
                    " buddy_id, buddy_unit,custom_count",
                    " from cooperate" +
                    " where buddy_id = #{buddyId,jdbcType=INTEGER}"
    })
    @Results(id = "CooperateMap",value = {
            @Result(id = true,column = "buddy_id",property = "buddyId"),
            @Result(column = "buddy_unit",property = "buddyUnit"),
            @Result(column = "custom_count",property = "customCount"),
    })
    Cooperate selectByPrimaryKey(Integer buddyId);

    /**
     * 按条件分页查询校区数据集合
     * @param rows 每页的行数
     * @param page 页码
     * @param condition 条件参数
     * @return 校区对象集合
     */
    @Select("select * from cooperate where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("CooperateMap")
    List<Cooperate> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 按条件查询school表中数据行数
     * @param condition 条件参数
     * @return 数据行数
     */
    @Select("select count(*) from cooperate where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);

    /**
     * 根据校区信息修改其数据
     * @param record 校区对象
     * @return 影响的行数(返回1则为成功)
     */
    @Update({
            "update cooperate",
            " set buddy_unit = #{buddyUnit,jdbcType=VARCHAR},custom_count = #{customCount,jdbcType=VARCHAR}",
            " where buddy_id = #{buddyId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Cooperate record);


}
